import os   
import platform
BgfxCppPath=[]
BgfxSources=[]
env=DefaultEnvironment().Clone()
OS_NAME=os.environ['TARGET_OS'];
LIB_DIR=os.environ['LIB_DIR'];
CCFLAGS=os.environ['CCFLAGS'];

BgfxCppPath=['bx/3rdparty',
                'bx/include',
                'bimg/include',
                'bgfx/3rdparty',
                'bgfx/3rdparty/khronos',
                'bimg/3rdparty/astc-codec/include',
                "bimg/3rdparty/astc-encoder/include",
                'bimg/3rdparty/astc-codec/',
                'bgfx/include']
BgfxSources = [
    "bx/src/amalgamated.cpp",
    'bimg/src/image.cpp',
    'bimg/src/image_gnf.cpp',
    'bgfx/src/amalgamated.cpp'
]
BgfxSources += Glob('bimg/3rdparty/astc-encoder/source/*.cpp')

if OS_NAME == 'Windows':
  CCFLAGS = CCFLAGS + ' /std:c++17 /Zc:__cplusplus ';
  BgfxCppPath = BgfxCppPath + ['bx/include/compat/msvc',
    'bgfx/3rdparty/dxsdk/include',
    'bgfx/3rdparty/directx-headers/include/directx']
elif OS_NAME == 'Darwin':
  CCFLAGS = CCFLAGS + ' -std=c++17 '
  BgfxCppPath= BgfxCppPath + ['bx/include/compat/osx']
  BgfxSources= BgfxSources + ['bgfx/src/renderer_mtl.mm']
elif OS_NAME == 'Linux':
  CCFLAGS = CCFLAGS + ' -std=c++17 '
  BgfxCppPath= BgfxCppPath + ['bx/include/compat/linux']
CCFLAGS = CCFLAGS + ' -DBX_CONFIG_DEBUG -DBIMG_DECODE_ENABLE=0 -DBGFX_CONFIG_MULTITHREADED=0 '        

env.Library(os.path.join(LIB_DIR, 'bgfx'), BgfxSources, CPPPATH = BgfxCppPath,CCFLAGS = CCFLAGS)

